package org.example.homework.mapper;


import org.apache.ibatis.annotations.*;
import org.example.homework.entity.User;
import org.springframework.expression.spel.ast.Literal;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into user (id, username, email, password) values (#{id}, #{username},#{email},#{password})")
    void insertUser(User user);
    @Select("select * from user where username = #{username}")
    User findByUsername(String username);
    @Select("select * from user where email = #{email}")
    User findByEmail(String email);
    @Select("select * from user where id = #{id}")
    User findById(int id);
    @Update("update user set password = #{newPassword} where id = #{userId}")
    void updatePassword(int userId, String newPassword);
    @Delete("delete from user where id = #{userId}")
    void deleteUser(int userId);
    @Select("select * from user")
    List<User> getAllUsers();
    @Update("update user set username = #{username}, email = #{email} where id = #{id}")
    void updateUser(User user);
}